package fi.foyt.cs.locale;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class Messages {

  public synchronized static Messages getInstance() {
    if (INSTANCE == null)
      INSTANCE = new Messages();
    
    return INSTANCE;
  }
  
  private static Messages INSTANCE;
  
  public String getText(Locale locale, String key) {
    return getResourceBundle(locale).getString(key);
  }
  
  public String getText(Locale locale, String key, Object... params) {
    return MessageFormat.format(getText(locale, key), params);
  }
  
  public ResourceBundle getResourceBundle(Locale locale) {
    return ResourceBundle.getBundle("fi.foyt.cs.locale.messages", locale); 
  }
  
}

